import Vue from '@/main.js';
import axios from 'axios'
//新增房屋
export function addroom(params) {

  // 部署好后的接口
  var path = "/business/room/insert";
  return Vue.$http.post(path, params).then((res) => {
  // 测试接口
  // var path = "http://192.168.124.171:8003/room/insert";
  // return axios.post(path, params).then((res) => {
    return res;
  })
    .catch(function (error) {
      console.log(error);
    });
}

//楼宇列表
export function getAddedUserList(params) {
  var path = "/business/building/list";
  return Vue.$http.post(path, params).then((res) => {
    return res.data.data;
  })
    .catch(function (error) {
      console.log(error);
    });
}

//获取下拉列表数据
export function getXiaLaList(category) {
  var path = `/business/dictionary/queryList?category=${category}`;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}

//获取上级机构列表
export function getShangJiJiGouList(code) {
  var path = `/business/company/getFatherCompanies?shortName=`;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}
//子级地区信息
export function getcityList(code) {
  var path = `/business/dictionary/queryAreaList?fatherCode=${code}`;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}

export function getcompanyList(agencyName, pid, pageNum, pageSize) {
  var path = "/business/company/list";
  return Vue.$http.post(path, {
    shortName: agencyName,
    pid: pid,
    pageNum: pageNum,
    pageSize: pageSize
  })
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}



export function getFatherAgencies(name) {
  var path = "/business/agency/getFatherAgencies?name=" + name;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}


export function insertAgency(reinsertForm) {
  var path = "/business/company/insert";
  return Vue.$http.post(path, reinsertForm)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}




export function deleteinstInformation(id) {
  var path = "/business/company/delete?id=" + id;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}
//下拉类型列表
export function DelRoom(id) {
  var path = `/business/room/delete?id=${id}`;
  return Vue.$http.get(path)
    .then((res) => {
      return res;
    })
    .catch(function (error) {
      console.log(error);
    });
}


export function getInDetail(id) {
  var path = "/business/room/detail?id=" + id;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}


export function updateinstInfo(params) {
  // 部署好后的接口
  var path = "/business/room/update";
  return Vue.$http.post(path, params)
  // 测试接口
  // var path = "http://192.168.124.171:8003/room/update";
  // return axios.post(path, params)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.log(error);
    });
}


export function getDictionaryList(category) {
  var path = "/business/dictionary/queryList?category=" + category;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export function bindingAU(agencyId, userId) {
  var path = "/business/company/bindingCU?companyId=" + agencyId + "&userId=" + userId;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export function unbindingAU(agencyId, userId) {
  var path = "/business/company/unbindingCU?companyId=" + agencyId + "&userId=" + userId;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}






export function getPostListByDepId(depId) {
  var path = "/business/companyPost/getPostListByDepId";
  return Vue.$http.post(path, {
    depId: depId,
  }).then((res) => {
    return res.data;
  })
    .catch(function (error) {
      console.log(error);
    });
}



export function addStaff(companyId, userIds, depIds, postIds) {
  var path = "/business/companyStaff/addStaff";
  return Vue.$http.post(path, {
    companyId: companyId,
    userIds: userIds,
    depIds: depIds,
    postIds: postIds,
  }).then((res) => {
    return res.data;
  })
    .catch(function (error) {
      console.log(error);
    });
}



// export function getAddedUserList(companyId, account, name) {
//   var path = "/business/companyStaff/addedStaffListByCompanyId";
//   return Vue.$http.post(path, {
//     companyId: companyId,
//     account: account,
//     name: name
//   }).then((res) => {
//     return res.data.data;
//   })
//     .catch(function (error) {
//       console.log(error);
//     });
// }

export function deleteStaff(staffId) {
  var path = "/business/companyStaff/delete?id=" + staffId;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export function getBreadcrumbs(agencyId) {
  var path = "/business/company/getFatherCompanyData?companyId=" + agencyId;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export function getAgencyStaffDetail(id) {
  var path = "/business/agencyStaff/detail?id=" + id;
  return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export function updateStaff(id, agencyId, userId, depIds, postIds) {
  var path = "/business/agencyStaff/updateStaff";
  return Vue.$http.post(path, {
    id: id,
    agencyId: agencyId,
    userId: userId,
    depIds: depIds,
    postIds: postIds,
  }).then((res) => {
    return res.data;
  })
    .catch(function (error) {
      console.log(error);
    });
}

